﻿module Library1
 
open Xunit

let rec sum list =
    match list with
    | head :: tail -> System.Int32.Parse(head) + sum tail
    | [] -> 0
 
let StringCalculator suppliedNumbers = 
    match suppliedNumbers with
    | "" | " " -> 0
    | x -> sum (x.Split(',')|>Seq.toList)
        

[<Fact>]
let TestMultiplyWithZeroInput() =
    Assert.Equal(0, StringCalculator "")
    Assert.Equal(0, StringCalculator " ")
    Assert.Equal(1, StringCalculator "1")
    Assert.Equal(100, StringCalculator "45,45,10")

[<Fact>]
let ShouldCalculate() =
    Assert.Equal(6, sum("1,2,3".Split(',') |> Seq.toList))

[<Fact>]
let TestSplitString() = 
    Assert.Equal(3,Seq.toList("1,2,3".Split(',')).Length)
    Assert.Equal(3,("1,2,3".Split(',') |> Seq.toList).Length)